package si.banst.tecajnice.entitete;

import static javax.persistence.EnumType.STRING;
import static javax.persistence.TemporalType.TIMESTAMP;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.Cacheable;

@Entity
@NamedQueries({
		@NamedQuery(name = "vrniVseValute", query = "SELECT v FROM Valuta v"),
		@NamedQuery(name = "vrniValutoZOznako", query = "SELECT v FROM Valuta v WHERE v.oznakaValute = :oznakaValute") })
@Cacheable
public class Valuta implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int sifraValute;

	@Temporal(TIMESTAMP)
	private Date datumCasSpremembe;

	private String nazivValute;

	private String oznakaValute;

	private String oznakaDrzave;

	private String nazivDrzave;

	private String referent;

	@Enumerated(STRING)
	private StatusAktivnosti statusAktivnosti;

	@OneToMany(mappedBy = "valuta")
	private List<Tecaj> tecaji;

	@OneToMany(mappedBy = "valuta")
	private List<Ponder> ponderji;

	public Valuta() {
		super();
	}

	public int getSifraValute() {
		return sifraValute;
	}

	public void setSifraValute(int sifraValute) {
		this.sifraValute = sifraValute;
	}

	public Date getDatumCasSpremembe() {
		return datumCasSpremembe;
	}

	public void setDatumCasSpremembe(Date datumCasSpremembe) {
		this.datumCasSpremembe = datumCasSpremembe;
	}

	public String getNazivValute() {
		return nazivValute;
	}

	public void setNazivValute(String nazivValute) {
		this.nazivValute = nazivValute;
	}

	public String getOznakaValute() {
		return oznakaValute;
	}

	public void setOznakaValute(String oznakaValute) {
		this.oznakaValute = oznakaValute;
	}

	public String getOznakaDrzave() {
		return oznakaDrzave;
	}

	public void setOznakaDrzave(String oznakaDrzave) {
		this.oznakaDrzave = oznakaDrzave;
	}

	public String getNazivDrzave() {
		return nazivDrzave;
	}

	public void setNazivDrzave(String nazivDrzave) {
		this.nazivDrzave = nazivDrzave;
	}

	public String getReferent() {
		return referent;
	}

	public void setReferent(String referent) {
		this.referent = referent;
	}

	public StatusAktivnosti getStatusAktivnosti() {
		return statusAktivnosti;
	}

	public void setStatusAktivnosti(StatusAktivnosti statusAktivnosti) {
		this.statusAktivnosti = statusAktivnosti;
	}

	public List<Tecaj> getTecaji() {
		return tecaji;
	}

	public void setTecaji(List<Tecaj> tecaji) {
		this.tecaji = tecaji;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + sifraValute;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Valuta))
			return false;
		Valuta other = (Valuta) obj;
		if (sifraValute != other.sifraValute)
			return false;
		return true;
	}

	public void setPonderji(List<Ponder> ponderji) {
		this.ponderji = ponderji;
	}

	public List<Ponder> getPonderji() {
		return ponderji;
	}

	@Override
	public String toString() {
		return "Valuta [sifraValute=" + sifraValute + ", datumCasSpremembe="
				+ datumCasSpremembe + ", nazivValute=" + nazivValute
				+ ", oznakaValute=" + oznakaValute + ", oznakaDrzave="
				+ oznakaDrzave + ", nazivDrzave=" + nazivDrzave + ", referent="
				+ referent + ", statusAktivnosti=" + statusAktivnosti + "]";
	}

}